package org.stvd.repository.logs.impl;

import java.util.Date;

import org.springframework.stereotype.Repository;
import org.stvd.core.dto.QueryResult;
import org.stvd.entities.logs.SysOperLog;
import org.stvd.repository.base.impl.BaseDaoImpl;
import org.stvd.repository.logs.SysOperLogDao;

/**
 * @Title: SysOperLodDaoImpl
 * @Description: 系统操作日志数据层接口实现类
 * @author houzx
 * @date 2020年9月2日
 */
@Repository("SysOperLogDao")
public class SysOperLodDaoImpl extends BaseDaoImpl<SysOperLog> implements SysOperLogDao{

    @Override
    public QueryResult<SysOperLog> queryOperLogResult(int start, int limit,
        String title, Integer businessType, Integer operatorType, String operIp, String operName, Integer status, 
        Date queryStartDate, Date queryEndDate) {
        String hql = "FROM SysOperLog WHERE title LIKE ?0"
            + " AND (businessType = ?1 OR ?1 IS NULL)"
            + " AND (operatorType = ?2 OR ?2 IS NULL)"
            + " AND (operIp = ?3 OR '' = ?3)"
            + " AND operName LIKE ?4"
            + " AND (status = ?5 OR ?5 IS NULL)"
            + " AND (operTime >= ?6 OR ?6 IS NULL)"
            + " AND (operTime < ?7 OR ?7 IS NULL)"
            + " ORDER BY operTime DESC";
        return getQueryResultByHQL(start, limit, hql, "%"+title+"%", businessType, operatorType, operIp,
             "%"+operName+"%", status, queryStartDate, queryEndDate);
    }

}
